package com.hytc.mymall.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hytc.mymall.R;
import com.hytc.mymall.base.MyBaseAdapter;
import com.hytc.mymall.utils.BaseTools;

import java.util.List;

/**
 * Created by Joker on 2016/12/1.
 */

public class LoginStyleAdapter extends MyBaseAdapter<String>
{
    private int selectIndex;

    public LoginStyleAdapter(final Context context, final List<String> list) {
        super(context, list);
        this.selectIndex = 0;
    }

    @Override
    public View getView(final int n, final View view, final ViewGroup viewGroup) {
        View inflate;
        ViewHolder tag;
        if (!false) {
            inflate = View.inflate(this.context, R.layout.layout_item_loginstyle, (ViewGroup)null);
            tag = new ViewHolder();
            tag.rl = (RelativeLayout)inflate.findViewById(R.id.rl_item_loginstyle);
            tag.tv = (TextView)inflate.findViewById(R.id.tv_item_loginstyle);
            inflate.setTag((Object)tag);
        }
        else {
            inflate = view;
            tag = (ViewHolder)inflate.getTag();
        }
        tag.rl.setLayoutParams((ViewGroup.LayoutParams)new AbsListView.LayoutParams(-1, BaseTools.dip2px(this.context, 50.0f)));
        if (n == this.selectIndex) {
            tag.tv.setTextColor(this.context.getResources().getColor(R.color.mainColor));
        }
        else {
            tag.tv.setTextColor(this.context.getResources().getColor(R.color.text_merchantcredit_dark));
        }
        tag.tv.setText((CharSequence)this.list.get(n));
        return inflate;
    }

    public void setSelectIndex(final int selectIndex) {
        this.selectIndex = selectIndex;
    }

    private class ViewHolder
    {
        public RelativeLayout rl;
        public TextView tv;
    }
}
